<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title> 客服系统</title>
    <link rel="stylesheet" href="/Public/css/just-tip.css">
    <link rel="stylesheet" href="/Public/css/toast.css">
    <link rel="stylesheet" href="/Public/css/bootstrap.min.css">
    <link rel="stylesheet" href="/Public/css/model.css">
    <link rel="stylesheet" href="/Public/css/gxxjkefu-normalize.css">
    <link rel="stylesheet" href="/Public/css/index.css">
    <link rel="stylesheet" href="/Public/css/page2.css">
    <link href="/Public/css/animate.css" rel="stylesheet">

    <style>
        .modal-backdrop {
            position: relative;
        }
        .common_btn {
            height: 30px;
            margin-right: 20px;
            border: solid 1px #ececec;
            border-radius: 5px;
            color: #5d5e60;
            background: none;
        }

        .common_btn:hover {
            color: white;
            background: #abdde6;
            border: solid 1px #abdde6;
        }

        .record_div {
            width: 100%;
            height: 50px;
            line-height: 50px;
            text-align: center;
        }

        .record_div div {
            display: inline-block;
            width: 32%;
        }

        .user_LV {
            position: absolute;
            right: 15%;
            top: 15%;
            font-size: 32px;
        }
    </style>
    <style>
        body {
            font-size: 12px;
            font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        }

        .menu_a a:hover {
            background: url("/Public/image/menu_a_active.png") no-repeat center bottom;
        }

        .menu_a_active {
            background: url("/Public/image/menu_a_active.png") no-repeat center bottom;
        }

        .page_a_btn {
            cursor: pointer;
            color: #ffffff !important;
            background-color: #49CFC4;
            border-color: #49CFC4;
            border-radius: 3px;
            padding: 2px 5px
        }

        .page_a_btn:hover {
            color: #ffffff !important;
            background-color: #49CFC4;
            border-color: #49CFC4;
            border-radius: 3px;
            padding: 2px 5px
        }

        .user_record {
            cursor: pointer;
            color: black;
        }

        .user_record:hover {
            color: #31b0d5;
        }
        .menu_a {
            /*width: 1000px;*/
            height: 90px;
            float: left;
            padding: 53px 0 0;
            position: relative;
        }

    </style>
</head>
<body>
<!--menu bar-->
<div class="menu_bar">
    <div class="LOGO"></div>
    <div class="menu_a">
        <a style="display: none" id="user_center_link" href="javascript:void(0);">用户中心</a>
        <a  style="display: none"  id="feedback_link" href="javascript:void(0);">在线反馈<span id="feedback_num" style="color: #d9534f;font-size: 18px">(0)</span></a>
        <a  style="display: none"  id="overdue_link" href="javascript:void(0);">逾期提醒</a>
        <a  style="display: none"  id="anti_user" href="javascript:void(0);">用户调查</a>
        <a id="outbound_user" href="javascript:void(0);">外呼用户</a>
        <a  style="display: none"  id="my_cert_user" href="javascript:void(0);">我的用户</a>
        <!--<a id="go_travel" href="javascript:void(0);">马上游呗</a>-->

    </div>
    <div class="right_user">
        <div class="phone_input" id="phone_div">
            <if condition="$agent_status neq 5">
                <div class="input-group" style="display: none">
                    <iframe id='id_phonebar' name="phone_bar"
                            src="<{$SERVER_NAME}>/PhoneBar/phonebar.html?loginName=<{$name}>&password=<{$password}>"
                            width="100%" frameborder="0" scrolling="no" marginheight="0"
                            style="text-decoration: none "></iframe>
                </div>
            </if>
            <div class="input-group">
                <input type="number" id="phone" onchange="get_user(1)" class="form-control form_control"
                       placeholder="手机号码">
                <div class="input-group-addon input_addon"><a href="javascript:;"><img
                        src="/Public/image/icon_phone.png" height="20" width="20" onclick="call_out()"/></a></div>
            </div>

        </div>
        <button class="btn_set" onclick="goto_set()"></button>
        <ul class="user_div">
            <li class="portrait_div">
                <img src="/Public/image/pic_avatar.png" height="33" width="33"/>
                <div class="state_img" id="status_img"></div>
                <div class="state_img2" style="display: none"></div>
                <div class="state_img3" style="display: none"></div>
                <div class="state_img4" style="display: none"></div>
            </li>
            <li class="location_li"><a id="state_PopOut_link" href="javascript:;"><span>工号<{$number}></span><span
                    class="triangle-down"></span></a></li>
            <span class="divide_line"></span>

            <li class=""><a href="<{$SERVER_NAME}>/Login/logout" onclick="logout()">退出 <span><img
                    src="/Public/image/icon_exit.png" height="14" width="12"/></span></a></li>

            <div id="state_PopOut" style="display: none">
                <ul class="state_PopOut">
                    <li><a class="state_PopOut_a1" href="javascript:;">空闲</a></li>
                    <li><a class="state_PopOut_a2" href="javascript:;">忙碌</a></li>
                    <li><a class="state_PopOut_a3" href="javascript:;">小休</a></li>
                    <li><a class="state_PopOut_a4" href="javascript:;">离线</a></li>
                </ul>
                <div class="state_triangle"></div>
            </div>
        </ul>
    </div>
</div>
<!--sidebar-->
<div class="sidebar_div">
    <!--选项-->
    <ul class="item_menu">
        <li class="active">
            <a id="home_link" href="javascript:void(0);">
                <span><img src="/Public/image/icon_work.png" height="21" width="16"/></span>
                <span>工单</span>
                <div class="triangle-up triangle-up_div"></div>
            </a>
        </li>
        <li>
            <a href="javascript:void(0);">
                <span><img src="/Public/image/icon_user.png" height="16" width="20"/></span>
                <span>同事</span>
                <div class="triangle-up_div"></div>
            </a>
        </li>
        <li>
            <a id="task_link" href="javascript:void(0);">
                <span><img src="/Public/image/icon_feedback.png" height="19" width="20"/></span>
                <span>任务</span>
                <div class="triangle-up_div"></div>
            </a>
        </li>
    </ul>
    <!--内容-->
    <!--工单-->
    <div class="table_content">
        <div>
            <div class="notice_title">
                <span class="notice_title_left">公告信息</span>
                <a id="notice_link" class="notice_title_right" href="javascript:;">更多></a>
            </div>
            <ul class="notice_ul" id="notice_list">
                <volist name="notice" id="vo">
                    <li onclick="notice_detail('<{$vo.id}>')"><a href="javascript:;"><{$vo.title}></a></li>
                </volist>
            </ul>
        </div>
        <div>
            <div class="notice_title">
                <span class="notice_title_left">工单动态</span>
                <a id="notice_link2" class="notice_title_right" href="javascript:;" onclick="create_order()">创建工单</a>
            </div>
            <ul class="work_order_ul" id="order_list">
                <volist name="order" id="vo">
                    <li>
                        <a href='javascript:;' onclick="order_detail('<{$vo.id}>')"><{$vo.publish_name}>向<{$vo.apart}>发起工单<{$vo.title}></a>
                        <div class="order_info">
                            <span class="order_time"><{$vo.ctime}></span>
                            <span class="order_state" style="float: right"><{$vo.status}></span>
                        </div>
                    </li>
                </volist>
            </ul>
            <div style="width: 80%;margin: 0 auto;clear: both">
                <div style="float: left; margin:20px 0 0;width: 100%">
                    <a class="page_a_btn" onclick="order_page(1)" style="float: left">上一页</a>
                    <a class="page_a_btn" onclick="order_page(2)" style="float: right">下一页</a>
                </div>
            </div>

        </div>
    </div>
    <!--同事-->
    <div style="display: none" class="table_content" id="mates">
        <ul class="colleague_ul" id="teammate_list">

        </ul>
        <div style="width: 80%;margin: 0 auto;clear: both">
            <div style="float: left; margin:20px 0 0;width: 100%">
                <a class="page_a_btn" onclick="mate_page(1)" style="float: left">上一页</a>
                <a class="page_a_btn" onclick="mate_page(2)" style="float: right">下一页</a>
            </div>
        </div>
    </div>
    <!--任务-->
    <div style="display: none" class="table_content">
        <div>
            <ul class="task_ul" style="background-color: #e5e5e5">
                <li onclick="kh_manager()">
                    <a href="javascript:;">客户经理专栏 >></a>
                </li>
            </ul>
            <ul class="task_ul" style="background-color: #e5e5e5">
            <li onclick="work_cert_list()">
                <a href="javascript:;">固定任务：工作认证审核</a>
                <p class="gray_color" style="margin-top: 15px;">任务时间：<{$check_time}></p>
                <if condition="$check_time eq ''">
                    <p class="orange_color">提醒：无任务</p>
                <else/>
                    <p class="orange_color">提醒：<{$time_s}></p>
                </if>
            </li>
            </ul>
            <ul class="task_ul" id="task_li">

            </ul>
            <div style="width: 80%;margin: 0 auto;clear: both">
                <div style="float: left; margin:20px 0 0;width: 100%">
                    <a class="page_a_btn" onclick="task_page(1)" style="float: left">上一页</a>
                    <a class="page_a_btn" onclick="task_page(2)" style="float: right">下一页</a>
                </div>
            </div>
        </div>
    </div>
</div>
<!--main-->
<div id="main_box">
    <div class="main_left">
        <iframe id="iframe" src="<{$SERVER_NAME}>/Home/home.html" width="100%" height="100%" style="border: none"
                scrolling="no" onload="url_change(this)"></iframe>
    </div>

    <ul class="main_right">
        <li>
            <div class="title_info">
                <span><a href="javascript:;" onclick="user_info()">用户信息</a></span>
                <input class="found_btn" type="button" value="创建任务"/>
                <input style="display: none" id="vid_text"/>
            </div>
            <ul class="user_info">
                <li><span>姓名：<span id="name" class="black_color"></span></span></li>
                <li><span>性别：<span id="sex" class="black_color"></span></span></li>
                <li id="user_phone">
                    <span>手机号：<span id="user_mobile" class="black_color"></span></span>
                    <span id="mobile" class="black_color" style="display: none"></span>
                    <div>
                        <input id="call_btn" class="phone_btn" type="button" onclick="call_user()"/>

                        <input class="message_btn" type="button" onclick="send_msg()"/>
                    </div>
                </li>
                <li><span>用户ID：<span id="user_id" class="black_color"></span></span></li>
                <li><span>认证状态：<span id="cert_status" class="black_color"></span></span></li>
                <li><span>注册时间：<span id="ctime" class="black_color"></span></span></li>
                <li><span>手机型号：<span id="mobile_firm" class="black_color"></span></span></li>
                <li><span>最近联系时间：<span id="contact_time" class="black_color">--:--:--</span></span></li>
                <li><span>用户所属：<span id="user_type" class="black_color"></span> </span></li>
            </ul>
        </li>

        <li>
            <div class="title_info">
                <span>通讯记录</span>
            </div>

            <div class="record_info">
                <div>
                    <a class="user_record"> <span onclick="call_recordList()">来电记录</span></a>
                    <span class="red_color" id="call_rec">(0)</span>
                </div>
                <div>
                    <a class="user_record"> <span onclick="feedback_online()">在线反馈</span></a>
                    <span class="red_color" id="feedback_rec">(0)</span>
                </div>
                <div>
                    <a class="user_record"> <span onclick="user_anti()">调查记录</span></a>
                    <span class="red_color" id="surve_rec">(0)</span>
                </div>
                <div>
                    <a class="user_record"> <span onclick="urge_record()">催收记录</span></a>
                    <span class="red_color" id="collection_rec">(0)</span>
                </div>
            </div>
        </li>
        <li id="action">
            <div class="title_info">
                <span>借还款记录</span>
            </div>
            <div class="record_info">
                <div>
                    <a class="user_record"> <span onclick="borrow_record()">借款记录</span> </a>
                    <span class="red_color" id="borrow_rec">(0)</span>
                </div>
                <div>
                    <a class="user_record"> <span onclick="repayment_record()">还款记录</span> </a>
                    <span class="red_color" id="pay_rec">(0)</span>
                </div>
                <div>

                    <a class="user_record"> <span onclick="stage_record()">分期记录</span> </a>
                    <span class="red_color" id="pay_stage">(0)</span>
                </div>
                <div>
                    <a class="user_record"> <span onclick="overdue_record()">逾期记录</span></a>
                    <span class="red_color" id="overdue_rec">(0)</span>
                </div>

                <div>
                    <a class="user_record"> <span onclick="part_record()">部分还款</span></a>
                    <span class="red_color" id="some_pay_rec">(0)</span>
                </div>
                <div>
                    <a class="user_record"> <span onclick="third_pay()">第三方支付记录</span></a>
                    <span class="red_color" id="third_pay_rec">(0)</span>
                </div>
                <div>
                    <a class="user_record"> <span onclick="overdue_fine()">逾期罚金减免记录</span></a>
                    <span class="red_color" id="reduce_pay_rec">(0)</span>
                </div>
                <div>
                    <a class="user_record"> <span onclick="quota_record()">额度变动记录</span></a>
                    <span class="red_color" id="quota_rec">(0)</span>
                </div>
            </div>
        </li>
        <li>

            <div class="title_info">
                <span>业务操作</span>
            </div>
            <div class="record_info operation_info">
                <div>
                    <span onclick="application_again()"><a>申请重新认证</a></span>
                </div>
                <div>
                    <span><a href="javascript:;" id="application_quota" onclick="applicaton_quota()">申请恢复额度</a></span>
                </div>

                <div>
                    <span onclick="coupon_send()"><a>优惠券派送</a></span>
                </div>
                <div>
                    <span onclick="cancel_debt()"><a>取消预约借款</a></span>
                </div>
                <div>
                    <span onclick="reduce_fine()"><a>申请减免罚金</a></span>
                </div>
                <div>
                    <span onclick="Debit()"><a>人工扣款</a></span>
                </div>
                <div>
                    <span onclick="urge_check()"><a>催促审核</a></span>
                </div>
                <div>
                    <span><a href="javascript:;" id="edit_user_info" onclick="edit_user()">修改基本信息</a></span>
                </div>
            </div>
        </li>
    </ul>

    <!--来电弹框 非平台用户-->
    <div class="modal fade bs-example-modal-sm1" id="other_call_in" backdrop="static"
         style="background: none;z-index: 999;" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div style="text-align: center">来电号码：<span id="call_phone">110 </span></div>
                <p style="font-size: 16px;margin: 20px 0 0 0">近30天的记录</p>
                <div class="record_div">
                    <div>来电记录<span id="modal1_in">3</span>条</div>
                    <div>去电记录<span id="modal2_out">3</span>条</div>
                </div>
                <input style="margin: 0 0 0 40%!important;" type="button" value="创建来电记录" onclick="create_record(1)"/>
            </div>
        </div>
    </div>
    <!--来电弹框 本平台用户-->
    <div class="modal fade bs-example-modal-sm2" id="user_call_in" style="z-index: 999;background: none" tabindex="-1"
         role="dialog" aria-labelledby="mySmallModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <p>姓名：<span id="modal_name">林元杰</span></p>
                <p>性别：<span id="modal_sex">男</span></p>
                <p>用户注册时间：<span id="modal_year">2年</span></p>
                <p style="font-size: 16px;margin: 20px 0 0 0">近30天的记录</p>
                <div class="record_div">
                    <div>来电记录<span id="modal_in">2</span>条</div>
                    <div>去电记录<span id="modal_out">3</span>条</div>
                    <div>反馈信息<span id="modal_feedback">3</span>条</div>
                </div>
                <p class="user_LV">VIP</p>
                <input style="margin: 0 0 0 40%!important;" type="button" onclick="create_record(2)" value="创建来电记录"/>
            </div>
        </div>
    </div>

</div>
<script src="/Public/js/jquery-3.2.1.js"></script>
<script src="/Public/js/justTools.js"></script>
<script src="/Public/js/toast.js"></script>
<script src="/Public/js/bootstrap.min.js"></script>
<script src="/Public/js/page2.js"></script>
<script src="/Public/js/echarts.min.js"></script>
<script src="/Public/js/main_c_link.js"></script>
<script src="/Public/js/layer/layer.js"></script>
<script src="/Public/js/layui/layui.js"></script>
<script type="text/javascript" src="/Public/js/icallcenter/global.js"></script>
<script type="text/javascript" src="/Public/js/icallcenter/hojotools.js"></script>
<script type="text/javascript" src="/Public/js/icallcenter/callProcessor.js"></script>
<script type="text/javascript" src="/Public/hojo/hojo.js" djConfig="isDebug:false, parseOnLoad:false"></script>
<script type="text/javascript" src="/Public/js/icallcenter/Phone.js"></script>
<script>

    var my_agent = "<{$agent}>"; //客服坐席
    //登录页判断
    function url_change(obj) {
        var url = obj.contentWindow.location.href;
        if (url.indexOf('login') != -1) {
            window.location.href = "<{$SERVER_NAME}>/Login/login.html";
        }
    }

    //设置
    function goto_set() {
        var rid = "<{$login_sys}>";
        if(rid==1){
            window.location.href = "<{$SERVER_NAME}>/admin.php";
        }else {
            window.location.href = "<{$SERVER_NAME}>/Admin/modifypwd.html";
        }

    }

    //   var webSocket=new WebSocket("ws://116.62.245.105:2018");
    //
    //    webSocket.onerror = function (event){
    //        onError(event);
    //    };
    //
    //    // 打开websocket
    //    webSocket.onopen = function (event){
    //        onOpen(event);
    //    };
    //
    //    //监听消息
    //    webSocket.onmessage = function (event){
    //        onMessage(event);
    //    };
    //
    //    webSocket.onclose = function (event){
    //        onClose(event);
    //    }
    //
    //    //关闭监听websocket
    //    function onError(event){
    //        console.log("error"+event.data);
    //    };
    //
    //    function onOpen(event){
    //        console.log("open:"+sockState());
    //    };
    //
    //    function onMessage(event){
    //        console.log("onMessage");
    //    };
    //
    //    function onClose(event){
    //        console.log("close:"+sockState());
    //        webSocket.close();
    //    }
    //
    //    function sockState(){
    //        var status = ['未连接','连接成功，可通讯','正在关闭','连接已关闭或无法打开'];
    //        return status[webSocket.readyState];
    //    }
    //
    //    function start(event){
    //        console.log(webSocket);
    //
    //        console.log("send:"+sockState());
    //        console.log("msg="+msg);
    //        webSocket.send("msg="+msg);
    //    };
    //
    //    function close(event){
    //        webSocket.close();
    //    }
</script>
<script type="text/javascript">
    sessionStorage.setItem('order_pageNum', 1);
    //同事分页 1 上一页 2 下一页
    function mate_page(type) {
        var oldpage = parseInt(sessionStorage.getItem('mate_pageNum'));
        var page = oldpage;
        if (type == 1) {
            if (oldpage <= 1) {
                $('#teammate_list').toast({
                    content: '已第一页！',
                    duration: 1000
                });
                return false;
            } else {
                sessionStorage.setItem('mate_pageNum', oldpage - 1);
                page = oldpage - 1;
            }
        } else if (type == 2) {
            sessionStorage.setItem('mate_pageNum', oldpage + 1);
            page = oldpage + 1;
        }

        var url = "<{$SERVER_NAME}>/Index/teammates";
        $.post(url, {page: page}, function (data) {
            if (data.code == '1001') {
                var obj = data.result;
                var s = "";
                for (var i = 0; i < obj.length; i++) {
                    //客服状态
                    var calss = "<span class='state_span1'>空闲</span> ";
                    var status = obj[i].agent_status;
                    switch (status) {
                        case '1'://空闲
                            calss = "<span class='state_span1'>空闲</span> ";
                            break;
                        case '2'://忙碌
                            calss = "<span class='state_span2'>忙碌</span> ";
                            break;
                        case '3'://3小休
                            calss = "<span class='state_span4'>小休</span> ";
                            break;
                        case '0'://0离线
                            calss = "<span class='state_span3'>离线</span> ";
                            break;
                        case '4'://4 离线
                            calss = "<span class='state_span3'>离线</span> ";
                            break;
                        case '5'://5 离线
                            calss = "<span class='state_span3'>离线</span> ";
                            break;
                    }
                    s += " <li> <div class='user_name_span' style='width: 100px'><span></span> <span class='demoRight' onmouseover=show_role(this,event,'" + obj[i].name + "','" + obj[i].role_name + "')>" + obj[i].name + " (0" + obj[i].agent_s + ")</span></div> " + calss + "<input type='button' class='service_change' onclick=transfer_to(this,event,'" + obj[i].agent + "') /> </li>";
                }
                document.getElementById("teammate_list").innerHTML = s;
            } else {
                $('#teammate_list').toast({
                    content: '无更多！',
                    duration: 1000
                });
            }
        });
    }

    //电话转接
    function transfer_to(obj, event, agent) {
        var _this = $(obj);
        _this.justToolsTip({
            confirm: true,
            animation: "moveInTop",
            contents: "确定要转接吗？",
            gravity: 'top',
            onYes: function (self) {
                var ag = agent.split('@');
//                  transfer('9'+ag[0],'external');
                window.frames['phone_bar'].transfer_to('9' + ag[0]);
//                window.frames['phone_bar'].transfer_to();
                self.close();
            },
            onNo: function (self) {
                console.log(self);
            }
        })
    }

    //显示部门职位
    function show_role(obj, event, name, role_name) {
        var _this = $(obj);
        _this.justToolsTip({
            events: event,
            animation: "moveInRight",
            contents: name + "  " + role_name,
            gravity: 'right'
        });
    }

    //工单分页 1 上一页 2 下一页
    function order_page(type) {
        var oldpage = parseInt(sessionStorage.getItem('order_pageNum'));
        var page = oldpage;
        if (type == 1) {
            if (oldpage <= 1) {
                $('#order_list').toast({
                    content: '已第一页！',
                    duration: 1000
                });
                return false;
            } else {
                sessionStorage.setItem('order_pageNum', oldpage - 1);
                page = oldpage - 1;
            }
        } else if (type == 2) {
            sessionStorage.setItem('order_pageNum', oldpage + 1);
            page = oldpage + 1;
        }
        var url = "<{$SERVER_NAME}>/Index/get_order";
        $.post(url, {page: page}, function (data) {
            if (data.code == '1001') {
                var orderObj = data.order;
                var order = "";
                for (var i = 0; i < orderObj.length; i++) {
                    order += " <li> <a href='javascript:;' onclick='order_detail(" + orderObj[i].id + ")'>" + orderObj[i].publish_name + "向" + orderObj[i].apart + "发起工单" + orderObj[i].title + "</a> <div class='order_info'> <span class='order_time'>" + orderObj[i].ctime + "</span> <span class='order_state' style='float: right'>" + orderObj[i].status + "</span> </div> </li>";

                }
                document.getElementById("order_list").innerHTML = order;
            } else {
                $('#order_list').toast({
                    content: '无更多！',
                    duration: 1000
                });
            }
        });

    }

    //任务分页 1 上一页 2 下一页
    function task_page(type) {
        var oldpage = parseInt(sessionStorage.getItem('task_pageNum'));
        var page = oldpage;
        if (type == 1) {
            if (oldpage <= 1) {
                $('#task_li').toast({
                    content: '已第一页！',
                    duration: 1000
                });
                return false;
            } else {
                sessionStorage.setItem('task_pageNum', oldpage - 1);
                page = oldpage - 1;
            }
        } else if (type == 2) {
            sessionStorage.setItem('task_pageNum', oldpage + 1);
            page = oldpage + 1;
        }
        var url = "<{$SERVER_NAME}>/User/task_list";
        $.post(url, {page: page}, function (data) {
            if (data.code == '1001') {
                var obj = data.result;
                var s = "";
                for (var i = 0; i < obj.length; i++) {
                    s += " <li> <a href='javascript:;' onclick='into_detail(" + obj[i].id + ")'>" + obj[i].title + "</a> <p class='gray_color' style='margin-top: 15px;'>任务时间：" + obj[i].task_time + "</p> ";

                    if (obj[i].status == 1) {

                        if (obj[i].over_date == 1) {//已超时
                            s += " <p class='orange_color'>提醒：任务已超时" + obj[i].day + "天" + obj[i].hour + "小时</p> ";
                        } else {
                            s += " <p class='orange_color'>提醒：距离任务还有" + obj[i].day + "天" + obj[i].hour + "小时</p> ";
                        }
                        s += "<span>状态：<span class='red_color'>未执行</span></span> ";
                    }

                    if (obj[i].status == 2) {
                        s += "<span>状态：<span class='blue_color'>已执行</span></span> ";
                    }
                    s += "</li>";
                }
                document.getElementById("task_li").innerHTML = s;
            } else {
                $('#task_li').toast({
                    content: '无更多！',
                    duration: 1000
                });
            }
        });
    }
</script>
<script>

    var phone_g = "";//来电号码
    var callid_g = "";//通话ID
    var agent_g = "";//坐席
    //用户基本信息
    function user_info() {
        var vid = empty_vid();
        if (vid == false) {
            layer.close(index);
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/user_info.html?vid=" + vid);
    }


    //电话条拨打电话给用户
    function call_out() {
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });

        var mobile = $("#phone").val();
        var url = "<{$SERVER_NAME}>/AntiUser/call";
        var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
        if (!myreg.test(mobile)) {
            layer.close(index);
            $('#phone_div').toast({
                content: '号码有误！',
                duration: 1000
            });
            return false;
        }
        layer.alert("确认外呼", {title: '提示框', icon: 3}, function (index) {
            $.post(url, {phone: mobile}, function (data) {

                if (data.code = '1001') {

                    var obj = data.result;
                    if (obj.Succeed == true) {

                        layer.alert("已响铃，请接听", {title: '提示框', icon: 1});
                    } else {
                        layer.alert("线路有误", {title: '提示框', icon: 2});
                    }
                } else {
                    layer.alert(data.result, {title: '提示框', icon: 2});
                }
                layer.close(index);
            });
        });
        layer.close(index);
    }
    //拨打电话给用户
    function call_user() {
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });
        var mobile = document.getElementById("mobile").innerText;
        var url = "<{$SERVER_NAME}>/AntiUser/call";
        var vid = empty_vid();
        if (vid == false) {
            layer.close(index);
            return false;
        }

        layer.alert("确认外呼", {title: '提示框', icon: 3}, function (index) {
            $.post(url, {phone: mobile}, function (data) {
                if (data.code = '1001') {
                    var obj = data.result;
                    if (obj.Succeed == true) {

                    } else {
                        layer.alert(obj.Succeed, {title: '提示框', icon: 2});
                    }

                } else {
                    layer.alert(data.result, {title: '提示框', icon: 2});
                }

                layer.close(index);
            });
            layer.close(index);
        });
        layer.close(index);
    }
    //坐席响铃触发
    function agent_onDialing(phone, callid) {

        phone_g = phone;
        callid_g = callid;
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });

        console.log('89898',phone+callid);
        layer.alert("已响铃，请接听并记录通话内容", {title: '提示框', icon: 1},function (index) {
            $('#phone').attr("disabled",true);
            $('#call_btn').hide();
            layer.close(index);
            var iframe = $("#iframe");
            iframe.attr('src', '<{$SERVER_NAME}>/User/add_tel_record.html?phone=' + phone + '&callid=' + callid);
        });
        layer.close(index);
    }
    //挂断
    function hang_up() {
         phone_g = "";
         callid_g = "";
        $('#phone').attr("disabled",false);
        $('#call_btn').show();
    }

    //获取用户手机
    function get_phone() {
        var phone = document.getElementById("mobile").innerText;
        return phone;
    }
    //获取用户id
    function get_vid() {
        var vid = document.getElementById("vid_text").value;
        return vid;
    }

    //发送短信给用户
    function send_msg() {
        var phone = document.getElementById("mobile").innerText;
        if (phone == "" || phone == null) {
            $('#action').toast({
                content: '没有选择用户！',
                duration: 1000
            });
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/User/send_msg.html");
    }
    //    20秒执行
    setInterval("get_order()", 20000);
    setInterval("get_mates()", 20000);
    setInterval("get_feedback_num()", 300000);
    get_feedback_num();

    function get_feedback_num() {
        $.post('<{$SERVER_NAME}>/Feedback/feedback_new',{},function (data) {
            console.log('8888800000',data);
         $('#feedback_num').html("("+data+")");
        });
    }

    //点击公告详情、
    function notice_detail(id) {
        var iframe = $("#iframe");
        iframe.attr('src', "/Order/notice_details?id=" + id);
    }

    //点击工单 详情
    function order_detail(id) {
        var iframe = $("#iframe");
        iframe.attr('src', "/Order/details.html?id=" + id);
    }

    /*客服状态切换*/
    $("#state_PopOut_link").click(function () {
        $("#state_PopOut").fadeToggle(500);
    });

    $(".state_PopOut").find("li").click(function () {
        $("#state_PopOut").fadeToggle(500);
        var index = $(this).index() + 1;
        agent_status(index);
        get_mates();
    });

    //坐席当前状态赋值

    function now_status() {
        var  index="<{$agent_status}>";
        var is = true;
        var status = 0;
        if (index == 1) {
            is = false;
            status = 0;//空闲
            $("#status_img").attr("class", "state_img");
        } else if (index == 2) {
            status = 1;// 忙碌
            $("#status_img").attr("class", "state_img2");
        } else if (index == 3) {
            status = 2;// 小休
            $("#status_img").attr("class", "state_img3");
        } else if (index == 4) {
            status = 2;// 离线
            $("#status_img").attr("class", "state_img4");
        }
        window.frames['phone_bar'].set_Busy(is, status);
    }

    function agent_status(index) {
        var url = "<{$SERVER_NAME}>/Index/change_status";
        $.post(url, {status: index}, function (data) {
            if (data.code == "1001") {
//                agent_status(index);
                var is = true;
                var status = 0;
                if (index == 1) {
                    is = false;
                    status = 0;//空闲
                    $("#status_img").attr("class", "state_img");
                } else if (index == 2) {
                    status = 1;// 忙碌
                    $("#status_img").attr("class", "state_img2");
                } else if (index == 3) {
                    status = 2;// 小休
                    $("#status_img").attr("class", "state_img3");
                } else if (index == 4) {
                    status = 2;// 离线
                    $("#status_img").attr("class", "state_img4");
                }
                window.frames['phone_bar'].set_Busy(is, status);
            } else {

            }
        });
    }

    //menu_a切换
    $(document).ready(function () {
        $(".menu_a a").click(function () {
            $(".menu_a").find("a").removeClass("menu_a_active");
            $(this).addClass("menu_a_active");
        });
    });

    function get_mates() {
        var url = "<{$SERVER_NAME}>/Index/teammates";
        $.post(url, {}, function (data) {
            if (data.code == '1001') {
                var obj = data.result;
                var s = "";
                for (var i = 0; i < obj.length; i++) {
                    //客服状态
                    var calss = "<span class='state_span1'>空闲</span> ";
                    var status = obj[i].agent_status;

                    switch (status) {
                        case '1'://空闲
                            calss = "<span class='state_span1'>空闲</span> ";

                            break;
                        case '2'://2 忙碌
                            calss = "<span class='state_span2'>忙碌</span> ";

                            break;
                        case '3'://3小休
                            calss = "<span class='state_span4'>小休</span> ";

                            break;
                        case '0'://3离线
                            calss = "<span class='state_span3'>离线</span> ";
                            break;

                        case '4'://4 离线
                            calss = "<span class='state_span3'>离线</span> ";
                            break;

                        case '5'://4 离线
                            calss = "<span class='state_span3'>离线</span> ";
                            break;
                    }
                    s += " <li> <div class='user_name_span' style='width: 100px'><span class='demoRight' onmouseover=show_role(this,event,'" + obj[i].name + "','" + obj[i].role_name + "')>" + obj[i].name + " (0" + obj[i].agent_s + ")</span></div>" + calss + "<input type='button' class='service_change' onclick=transfer_to(this,event,'" + obj[i].agent + "') /> </li>";
                }
                document.getElementById("teammate_list").innerHTML = s;
            }
        });
    }

    function get_task() {
        var url = "<{$SERVER_NAME}>/User/task_list";
        $.post(url, {}, function (data) {
            if (data.code == '1001') {
                var obj = data.result;
                var s = "";

                for (var i = 0; i < obj.length; i++) {
                    s += " <li> <a href='javascript:;' onclick='into_detail(" + obj[i].id + ")'>" + obj[i].title + "</a> <p class='gray_color' style='margin-top: 15px;'>任务时间：" + obj[i].task_time + "</p>";

                    if (obj[i].status == 1) {

                        if (obj[i].over_date == 1) {//已超时
                            s += " <p class='orange_color'>提醒：任务已超时" + obj[i].day + "天" + obj[i].hour + "小时</p> ";
                        } else {
                            s += " <p class='orange_color'>提醒：距离任务还有" + obj[i].day + "天" + obj[i].hour + "小时</p> ";
                        }
                        s += "<span>状态：<span class='red_color'>未执行</span></span> ";
                    }
                    if (obj[i].status == 2) {
                        s += "<span>状态：<span class='blue_color'>已执行</span></span> ";
                    }
                    s += "</li>";
                }
                document.getElementById("task_li").innerHTML = s;
            }
        });
    }
    function get_order() {
        var url = "<{$SERVER_NAME}>/Index/noticeOrder";
        $.post(url, {}, function (data) {
            if (data.code == '1001') {
                var noticeObj = data.notice;
                var orderObj = data.order;
                var s = "";
                for (var i = 0; i < noticeObj.length; i++) {
                    s += " <li><a onclick=notice_detail(" + noticeObj[i].id + ") >" + noticeObj[i].title + "</a></li>";
                }
                document.getElementById("notice_list").innerHTML = s;
                var order = "";
                for (var i = 0; i < orderObj.length; i++) {
                    order += " <li> <a onclick='order_detail(" + orderObj[i].id + ")'>" + orderObj[i].publish_name + "向" + orderObj[i].apart + "发起工单" + orderObj[i].title + "</a> <div class='order_info'> <span class='order_time'>" + orderObj[i].ctime + "</span> <span class='order_state' style='float: right'>" + orderObj[i].status + "</span> </div> </li>";
                }
                document.getElementById("order_list").innerHTML = order;
            }
        });
    }
    //选项卡切换
    $(document).ready(function () {
        $(".item_menu li").click(function () {

            $(".table_content").hide().eq($(this).index()).show();
            $(".item_menu").find("li").removeClass("active");
            $(this).addClass("active");
            $(".item_menu").find("a div").removeClass("triangle-up");
            $(this).find("a div").addClass("triangle-up");

            var index = $(this).index() + 1;//获取索引
            if (index == 2) {//同事
                sessionStorage.setItem('mate_pageNum', 1);//设置页数为第一页；
                get_mates();
            } else if (index == 3) {//任务
                sessionStorage.setItem('task_pageNum', 1);
                get_task();
            } else {//默认工单1
                sessionStorage.setItem('order_pageNum', oldpage - 1);
                get_order();
            }
        });
    });
    // //获取用户信息
    function get_user(mobile) {
        //     var url = "<{$SERVER_NAME}>/Index/get_user";
        //     if (mobile != 1) {
        //         var phone = mobile;
        //     } else {
        //         var phone = $("#phone").val();
        //     }
        //     $.post(url, {phone: phone}, function (data) {
        //         if (data.code == '1001') {
        //             var obj = data.result;
        //             var rec_obj = data.rec_data;
        //             document.getElementById("name").innerHTML = obj.truename;
        //             document.getElementById("user_mobile").innerHTML = obj.user_mobile;
        //             document.getElementById("mobile").innerHTML = obj.mobile;
        //             document.getElementById("sex").innerHTML = obj.sex;
        //             document.getElementById("cert_status").innerHTML = obj.cert_status;
        //             document.getElementById("ctime").innerHTML = obj.ctime;
        //             document.getElementById("user_id").innerHTML = obj.user_id;
        //             document.getElementById("contact_time").innerHTML = obj.recent_contact;
        //             document.getElementById("user_type").innerHTML = obj.user_type;
        //             document.getElementById("mobile_firm").innerHTML = obj.mobile_firm;
        //             $("#vid_text").val(obj.vid);
        //             var vid = document.getElementById("vid_text").value;
        //             // document.getElementById("call_rec").innerHTML = "(" + rec_obj.call_record + ")";
        //             document.getElementById("feedback_rec").innerHTML = "(" + rec_obj.feedback_rec + ")";
        //             document.getElementById("surve_rec").innerHTML = "(" + rec_obj.surve_rec + ")";
        //             document.getElementById("collection_rec").innerHTML = "(" + rec_obj.urge_rec + ")";
        //             document.getElementById("borrow_rec").innerHTML = "(" + rec_obj.borrow_rec + ")";
        //             document.getElementById("pay_rec").innerHTML = "(" + rec_obj.repay_rec + ")";
        //             document.getElementById("pay_stage").innerHTML = "(" + rec_obj.stages_rec + ")";
        //             document.getElementById("overdue_rec").innerHTML = "(" + rec_obj.overdue_rec + ")";
        //             document.getElementById("some_pay_rec").innerHTML = "(" + rec_obj.part_rec + ")";
        //             document.getElementById("third_pay_rec").innerHTML = "(" + rec_obj.third_rec + ")";
        //             document.getElementById("reduce_pay_rec").innerHTML = "(" + rec_obj.reduce_pay_rec + ")";
        //             document.getElementById("quota_rec").innerHTML = "(" + rec_obj.quota_count + ")";
        //
        //         } else {
        //             document.getElementById("name").style.visibility = "";
        //             document.getElementById("user_mobile").style.visibility = "";
        //             document.getElementById("mobile").style.visibility = "";
        //             document.getElementById("sex").style.visibility = "";
        //             document.getElementById("cert_status").style.visibility = "";
        //             document.getElementById("ctime").style.visibility = "";
        //             document.getElementById("contact_time").innerHTML = "";
        //             document.getElementById("mobile_firm").innerHTML = "";
        //             document.getElementById("user_id").innerHTML = "";
        //             $("#vid_text").val("");
        //             document.getElementById("feedback_rec").innerHTML = "(0)";
        //             document.getElementById("call_rec").innerHTML = "(0)";
        //             document.getElementById("surve_rec").innerHTML = "(0)";
        //             document.getElementById("collection_rec").innerHTML = "(0)";
        //             document.getElementById("borrow_rec").innerHTML = "(0)";
        //             document.getElementById("pay_rec").innerHTML = "(0)";
        //             document.getElementById("pay_stage").innerHTML ="(0)";
        //
        //             document.getElementById("overdue_rec").innerHTML = "(0)";
        //             document.getElementById("some_pay_rec").innerHTML = "(0)";
        //             document.getElementById("third_pay_rec").innerHTML = "(0)";
        //             document.getElementById("reduce_pay_rec").innerHTML = "(0)";
        //             document.getElementById("quota_rec").innerHTML = "(0)";
        //         }
        //     });
        // }
    }
    //点击任务列表 O区显示详情
    function into_detail(id) {
        var iframe = $("#iframe");
        iframe.attr('src', "/User/task.html?task_id=" + id);
    }

    //优惠券派送
    function coupon_send() {

        var vid = empty_vid();
        if (vid == false) {
            return false;
        }

        var phone = document.getElementById("mobile").innerText;
        layer.open({
            title: '派送优惠券',
            type: 2,
            area: ['30%', '25%'],
            maxmin: true,
            offset: '100px',
            content: '<{$SERVER_NAME}>/User/coupon_view.html?phone=' + phone,
            success: function (layero) {
                layero.find('.layui-layer-min').remove();
            }
        });

    }
    //人工扣款
    function Debit() {
        var phone = document.getElementById("mobile").innerText;
        if (phone == "" || phone == null) {
            $('#action').toast({
                content: '没有选择用户！',
                duration: 1000
            });
            return false;
        }

        var url = "<{$SERVER_NAME}>/User/Debit";
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });

        layer.alert("确定人工扣款？", {title: '提示框', icon: 3}, function (index) {
            $.post(url, {phone: phone}, function (data) {

                if (data.code == "1001") {
                    $('#action').toast({
                        content: data.result,
                        duration: 1000
                    });

                }
                else {
                    layer.alert(data.result, {title: '提示框', icon: 2});
                    layer.close(index);
                }

            });
            layer.close(index);
        });
        layer.close(index);
    }
    //修改信息
    function edit_user() {
        var iframe = $("#iframe");
        var vid = document.getElementById("vid_text").value;
        if (vid == "" || vid == null) {
            $('#action').toast({
                content: '没有选择用户！',
                duration: 1000
            });
            return false;
        }
        iframe.attr('src', "/User/edit_user_info.html?vid=" + vid);
    }

    //创建工单
    function create_order() {
        var iframe = $("#iframe");
        iframe.attr('src', "/Order/create_order.html");

    }
    //申请额度
    function applicaton_quota() {
        var vid = document.getElementById("vid_text").value;
        if (vid == "" || vid == null) {
            $('#action').toast({
                content: '没有选择用户！',
                duration: 1000
            });
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/User/user_apply_quota.html?vid=" + vid);
    }

    //申请减免罚金
    function reduce_fine() {
        var vid = document.getElementById("vid_text").value;
        if (vid == "" || vid == null) {
            $('#action').toast({
                content: '没有选择用户！',
                duration: 1000
            });
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/User/overdue_list.html?vid=" + vid);
    }
    //取消预约续借
    function cancel_debt() {
        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/User/user_debt.html?vid=" + vid);
    }

    //申请重新认证
    function application_again() {
        var phone = document.getElementById("mobile").innerText;
        if (phone == "" || phone == null) {
            $('#action').toast({
                content: '没有选择用户！',
                duration: 1000
            });
            return false;
        }
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });
        var url = "<{$SERVER_NAME}>/User/application_again";
        layer.alert("确定申请重审核？", {title: '提示框', icon: 3}, function (index) {

            $.post(url, {phone: phone}, function (data) {
                console.log('33331',data);
                if (data.ret == "1001") {
                    $('#action').toast({
                        content: data.result,
                        duration: 1000
                    });
                } else {
                    layer.alert(data.result);
                }
            });
            layer.close(index);
        });
        layer.close(index);
    }

    //催促审核
    function urge_check() {
        var phone = document.getElementById("mobile").innerText;
        if (phone == "" || phone == null) {
            $('#action').toast({
                content: '没有选择用户！',
                duration: 1000
            });
            return false;
        }

        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });

        var url = "<{$SERVER_NAME}>/User/urge_pass";
        layer.alert("确定催促审核？", {title: '提示框', icon: 3}, function (index) {
            $.post(url, {phone: phone}, function (data) {
                if (data.code == "1001") {
                    $('#action').toast({
                        content: data.result,
                        duration: 1000
                    });
                } else {
                    layer.alert(data.result);
                }
            });
            layer.close(index);
        });
        layer.close(index);
    }

    //借款记录
    function borrow_record() {

        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/borrow_record.html?vid=" + vid);


    }

    //还款记录
    function repayment_record() {

        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/repayment_record.html?vid=" + vid);
    }
    //分期记录
    function stage_record() {

        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/stage_record.html?vid=" + vid);
    }

    //逾期记录
    function overdue_record() {
        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/overdue_record.html?vid=" + vid);
    }
    //部分还款记录
    function part_record() {

        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/part_repayment_record.html?vid=" + vid);
    }
    //第三方支付记录
    function third_pay() {

        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/third_pay.html?vid=" + vid);

    }

    //逾期罚金减免记录
    function overdue_fine() {
        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/overdue_fine.html?vid=" + vid);

    }

    //额度变动日志
    function quota_record() {
        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/quota_record.html?vid=" + vid);

    }

    // //来电记录
    // function call_recordList() {
    //     var vid = empty_vid();
    //     if (vid == false) {
    //         return false;
    //     }
    //     var iframe = $("#iframe");
    //     iframe.attr('src', "/UserCenter/call_record.html?vid=" + vid + "&page=1");
    // }

    //在线记录
    function feedback_online() {
        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/feedback_online.html?vid=" + vid + "&page=1");
    }


    //用户调查
    function user_anti() {
        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/antiList_record.html?vid=" + vid);
    }

    //用户调查
    function urge_record() {
        var vid = empty_vid();
        if (vid == false) {
            return false;
        }
        var iframe = $("#iframe");
        iframe.attr('src', "/UserCenter/urge_record.html?vid=" + vid);
    }

    //判断用户是否存在
    function empty_vid() {
        var vid = document.getElementById("vid_text").value;
        if (vid == "" || vid == null) {
            $('#action').toast({
                content: '没有选择用户！',
                duration: 1000
            });
            return false;
        } else {
            return vid;
        }
    }

    //来电弹框
    function call_record(phone, callid, agent) {
        var my_agent1 = my_agent.split('@');
        if (agent == my_agent1[0]) {
            phone_g = phone;
            callid_g = callid;
            agent_g = agent;
            //判断是否平台用户
            $.post("<{$SERVER_NAME}>/Index/get_call_user", {phone: phone}, function (data) {
                if (data.code = '1001') {
                    var obj = data.data;
                    //平台用户
                    if (data.is_jyy == 1) {
                        $('#modal_name').html(obj.truename);
                        $('#modal_sex').html(obj.sex);
                        $('#modal_year').html(obj.ctime);
                        $('#modal_in').html(obj.call_in);
                        $('#modal_out').html(obj.call_out);
                        $('#modal_feedback').html(obj.feedback_rec);
                        $('#user_call_in').modal({backdrop: "static", keyboard: false, show: true});
                    } else if (data.is_jyy == 2) {
                        $('#call_phone').html(obj.phone);
                        $('#modal1_in').html(obj.call_in);
                        $('#modal1_out').html(obj.call_out);
                        $('#other_call_in').modal({backdrop: "static", keyboard: false, show: true});
                    }
                }
            });
        }
    }

    // 创建通话记录
    function create_record(type) {
        if (type == 1) {
            $('#other_call_in').modal('hide');//隐藏模态框
        } else {
            $('#user_call_in').modal('hide');//隐藏模态框
        }
        var iframe = $("#iframe");
        iframe.attr('src', '<{$SERVER_NAME}>/User/add_tel_record.html?phone=' + phone_g + '&callid=' + callid_g);
    }

    //工作认证审核列表
    function work_cert_list() {
        var iframe = $("#iframe");
        iframe.attr('src', '<{$SERVER_NAME}>/WorkCert/work_cert_list.html');
    }

  //工作认证审核列表
    function kh_manager() {

        var iframe = $("#iframe");
        iframe.attr('src', '<{$SERVER_NAME}>/MyUser/manager_user.html');
    }

    //电话登出
    function logout() {
//        window.frames['phone_bar'].log_out();
    }
    now_status();
</script>
</body>
</html>